{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "%matplotlib inline\n",
    "import matplotlib\n",
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "import dateutil\n",
    "import analysis\n",
    "\n",
    "packets = analysis.parse_packet_file('data/all.txt')\n",
    "packets += analysis.parse_packet_file('data/temp_basals.txt')\n",
    "\n",
    "# Select valid packets\n",
    "packets = filter(lambda x: x.is_valid() and x.body_len == 3, packets)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2016-06-26T20:33:28.412197 ID1:1f01482a PTYPE:PDM SEQ:13 ID2:1f01482a B9:10 BLEN:3 MTYPE:0e01 BODY:00802c CRC:88\n"
     ]
    }
   ],
   "source": [
    "print packets[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1f01482aad1f01482a10030e0100802c88\n"
     ]
    }
   ],
   "source": [
    "print packets[0].tx_data().encode('hex')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "def split_parts(data, idx):\n",
    "    return (ord(data[idx]), (data[4:idx] + data[idx+1:-3]).encode('hex'), data[-3:-1].encode('hex'))\n",
    "\n",
    "def get_parts_df(pos, packets):\n",
    "    parts = [split_parts(p.tx_data(), pos) for p in packets] \n",
    "    parts_df = pd.DataFrame(parts, columns=[\"byte\", \"other\", \"hash\"])\n",
    "    parts_df.drop_duplicates(inplace=True)\n",
    "    return parts_df\n",
    "\n",
    "def analyze_parts(parts_df):\n",
    "    # Number of times byte changes independently of 'other'\n",
    "    independent_change_count = parts_df.groupby(['other']).count()['byte'].max() - 1\n",
    "    # Max number of times byte changed independently of hash\n",
    "    # Higher number here means not likely to be included in hash\n",
    "    hash_independent_change_count = parts_df.groupby(['hash', 'other']).count()['byte'].max() - 1\n",
    "    # Number of times hash changed dependent on byte\n",
    "    dependent_change_count = parts_df.groupby(['other']).count()['hash'].max() - 1\n",
    "    return (independent_change_count, hash_independent_change_count, dependent_change_count)\n",
    "\n",
    "plen = len(packets[0].tx_data())\n",
    "# For all bytes except the last three (2-byte hash and crc8)\n",
    "stats = [analyze_parts(get_parts_df(i, packets)) for i in range(4, plen-3)]\n",
    "stats = pd.DataFrame(stats, columns=['ichange', 'hichange', 'dchange'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.axes._subplots.AxesSubplot at 0x112895450>"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAW0AAAD8CAYAAAC8TPVwAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAD/9JREFUeJzt3XuM5WV9x/H3BwYsiKBF3VVXF62htVYk1IKpVk+1CvVG\nay9R6rXRJvUCbQzx1mTnnxrbtLGm/Yu4bjR1awr1Ao0XSvW0od5QWHeRpRovgCBTtYhRjBX59o/z\n23U8OzNnOLc5z/p+JSf7m+c85/d8Z+a3n3nmu+fsSVUhSWrDMVtdgCRp8wxtSWqIoS1JDTG0Jakh\nhrYkNcTQlqSGjAztJLuTrCTZPzT+2iQHkxxI8tbZlShJOmRpE3P2AH8PvPvQQJIe8FzgcVV1d5IH\nzqY8SdJqI3faVXU1cMfQ8J8Cb62qu7s535pBbZKkIeP2tE8HnpLkU0k+nuQJ0yxKkrS2zbRH1nvc\nA6rqiUl+Dfhn4FFrTUzi6+QlaQxVleGxcXfatwDv6056DXBPklM3WHjdWzdjxG3XiPs3XmMat127\nds18jVbqWIQaFq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YG4OfTsetMX48g5fML0KNN89pnQPASd3x\nacBnGQQ3wHVz/HwPAMcy+IvxXeDkbvwEYP+cargW+EegBzy1+/Mb3fFT5/i1uG7V8TXAg7rj+wIH\n5lTDwdVfl6H79s3za8GgvfpMYDfwTeAjwEuB+82phv3dn0vACnBs93HmdW126x1YtfaJQL87fsQs\n/q4uWnvkHuChwE1D4w/p7puLJPvXuwvYNqcyjqmuJVJVX0vSAy5LsrOrY17urqofA3cl+XJ1v+5V\n1Q+SzOt78gTgIuDNwMVVtS/JD6rqP+a0/iHHJHkAg7A6trqdZVV9P8ndc6rh+lW/7X0+yROq6rNJ\nTgfm1g5g0C67h8FTfq9MchyD38heCPwN8KA51HBM1yK5L4OwPAX4X+A+wHFzWH+1JQZtkfsw2PFT\nVTd3X5epL7RI/gz49yRf4if/r8kjgEcDr5ljHdsY/O+FdwyNB/jEnGpYSXJmVe0DqKrvJXkO8E7g\ncXOqAeD/kpxYVXcBv3poMMkpzOkHaRcOb0tyaffnCltz7Z4CfI7BdVBJHlJV30hyEvP7QfoK4O1J\n/gL4FvDJJLcw+PvyijnVAEOfbw36x5cDlyc5cU417AZuZPCb4JuBS5N8BXgigxbrvLwDuCbJp4Hf\nAP4KIMmDGPwQmaqF6mnD4f/y9Wx++h8ir+l2e/OqYTewp6quXuO+vVV1wRxq2MFgl3v7Gvc9qar+\na9Y1dGvdp6p+uMb4A4GHVNWBedQxtPazgSdV1ZvmvfZaupDaVlVfneOaJwOPZPDD6+tVtTKvtbv1\nT6+qL85zzXXqeChAVd2W5P7AbzFoYX5mznU8FngMg3+UvnGmay1aaEuS1ufztCWpIYa2JDXE0Jak\nhhjaktSQ/wev7UM0eyyqNAAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x1125da7d0>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "stats['ichange'].plot.bar()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.axes._subplots.AxesSubplot at 0x112c4ef90>"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAW0AAAD8CAYAAAC8TPVwAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAD4VJREFUeJzt3XuspHV9x/H3Bw5YEEGLCuoqag2ttSKhFky1OtUq1But\nvUSJ10ab1Au0MUTFJnv+qbFNG2vav4jrRlO3plAv0HihVKeGekNh3UWWatQCgp6qRYxirMi3f8yz\n63H2zJk5M3OG+W3fr2SyzzzzzPP7zNnZz/md386cSVUhSWrDUfd2AEnS5CxtSWqIpS1JDbG0Jakh\nlrYkNcTSlqSGjC3tJLuSrCXZN7T/dUkOJNmf5K3bF1GSdNDKBMfsBv4OePfBHUl6wPOAx1fV3Uke\nuD3xJEnrjZ1pV9U1wB1Du/8EeGtV3d0d8+1tyCZJGjLtmvbpwFOTfDrJx5M8cZ6hJEkbm2R5ZNT9\nHlBVT0rya8A/AY/e6MAkvk9ekqZQVRneN+1M+1bgfd1JrwXuSXLyJgOPvHRHjLnsHHP75mPM47Jz\n585tH6OVHMuQYVlyLEOGZcmxDBmWJcc8MowyaWmnuxz0AeDpAElOB46pqu9MeC5J0pTGLo8k2QP0\ngJOT3MJg2vtOYHeS/cCPgJduZ0hJ0sDY0q6qC0bc9JI5Z9lEb3FDjUrQu/czwHLkWIYMsBw5liED\nLEeOZcgAy5FjOzNks7WTuQyQ1GZjJOHguvQMo2y6BiRJrUlCzfE/IiVJ9wJLW5IaYmlLUkMsbUlq\niKUtSQ2xtCWpIZa2JDXE0pakhljaktQQS1uSGmJpS1JDLG1JaoilLUkNsbQlqSGWtiQ1xNKWpIZY\n2pLUEEtbkhoytrST7EqylmTfBre9Psk9SX5+e+JJktabZKa9Gzh3eGeSHcAzgZvnHUqStLGx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ggb6RdObwtyWXdn2vcO8/dk4DPM3geVJKHVNU3kpzA4r6RvhJ4e5I/B74NfCrJ\nrQz+vbxyQRlg6PHWYP34CuCKJMcvKMMu4CYGPwm+GbgsyVeBJzFYYl2UdwDXJvkM8BvAXwIkeRCD\nbyJztVRr2nDoV76ezc/+R+S13WxvURl2Abur6poNbttTVRcsIMMOBrPcb25w25Or6j+2O0M31n2q\n6kcb7H8g8JCq2r+IHENjPwd4clVdsuixN9KV1ClV9bUFjnki8CgG37y+XlVrixq7G//0qvrSIscc\nkeOhAFV1e5L7A7/FYAnzswvO8TjgsQz+U/qmbR1r2UpbkjSar9OWpIZY2pLUEEtbkhpiaUtSQ/4P\nzi/4WBx6wkYAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x112c57b10>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "stats['hichange'].plot.bar()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.axes._subplots.AxesSubplot at 0x112e04290>"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAW0AAAD8CAYAAAC8TPVwAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAD/9JREFUeJzt3XuM5WV9x/H3BwYsiKBF3VVXF62htVYk1IKpVk+1CvVG\nay9R6rXRJvUCbQzx1mTnnxrbtLGm/Yu4bjR1awr1Ao0XSvW0od5QWHeRpRovgCBTtYhRjBX59o/z\n23U8OzNnOLc5z/p+JSf7m+c85/d8Z+a3n3nmu+fsSVUhSWrDMVtdgCRp8wxtSWqIoS1JDTG0Jakh\nhrYkNcTQlqSGjAztJLuTrCTZPzT+2iQHkxxI8tbZlShJOmRpE3P2AH8PvPvQQJIe8FzgcVV1d5IH\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yqNAAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x112e040d0>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "stats['dchange'].plot.bar()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.11"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
